<template>
  <page-header-wrapper>
    <a-result title="该功能暂未开放" @click="notopened" style="padding-top: 120px">
      <template #extra>
      </template>
    </a-result>
    <div style="display:none">
      <a-card :bordered="false" v-show="disvisible===0">
        <a-icon type="menu-fold" @click="turnSmall" class="turnSmall" v-if="treespan===4"></a-icon>
        <a-icon type="menu-unfold" @click="turnSmall" class="turnSmall" v-if="treespan===0"/>
        <a-row :gutter="13">
          <a-col :span="treespan">
            <a-skeleton active :paragraph="{ rows: 5 }" :loading="menuLoading" />
            <s-tree
              :dataSource="orgTree"
              :openKeys.sync="openKeys"
              :search="false"
              @click="handleClick"
              @titleClick="handleTitleClick"></s-tree>
          </a-col>
          <a-col :span="tablespan">
            <!-- <a-skeleton active :paragraph="{ rows: 5 }" :loading="menuLoading" /> -->
            <a-table
              ref="table"
              size="default"
              :loading="loading"
              :columns="columns"
              :row-key="record => record.project_id"
              :data-source="dataSource"
              :alert="false"
              :pagination="pagination"
              @change="handlePageChange"
              :maskClosable="false"
              bordered
            >
              <div
                slot="filterDropdown"
                slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
                style="padding: 8px"
              >
                <a-input
                  v-ant-ref="c => (searchInput = c)"
                  :placeholder="`搜索 ${column.dataIndex}`"
                  :value="selectedKeys[0]"
                  style="width: 188px; margin-bottom: 8px; display: block;"
                  @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
                  @pressEnter="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
                />
                <a-button
                  type="primary"
                  icon="search"
                  size="small"
                  style="width: 90px; margin-right: 8px"
                  @click="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
                >
                  搜索
                </a-button>
                <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters)">
                  重置
                </a-button>
              </div>
              <a-icon
                slot="filterIcon"
                slot-scope="filtered"
                type="search"
                :style="{ color: filtered ? '#108ee9' : undefined }"
              />
              <template slot="customRender" slot-scope="text, record, index, column">
                <span v-if="searchText && searchedColumn === column.dataIndex">
                  <template
                    v-for="(fragment, i) in text
                      .toString()
                      .split(new RegExp(`(?<=${searchText})|(?=${searchText})`, 'i'))"
                  >
                    <mark
                      v-if="fragment.toLowerCase() === searchText.toLowerCase()"
                      :key="i"
                      class="highlight"
                    >{{ fragment }}</mark
                    >
                    <template v-else>{{ fragment }}</template>
                  </template>
                </span>
                <template v-else>
                  {{ text }}
                </template>
              </template>
              <span slot="mobile" slot-scope="text, record">
                <a-switch :checked="record.is_mobile" @change="onChangeMobile(record)" />
              </span>
              <span slot="action" slot-scope="text, record">
                <span v-if="record.review_status === '初评'">
                  <a-popconfirm
                    title="确定操作?"
                    okText="确定"
                    cancelText="取消"
                    @confirm="() => handleRevoke(record)"
                  >
                    <a>撤销</a>
                  </a-popconfirm>
                  <!-- <a-divider type="vertical" /> -->
                  <!-- <a @click="createPass(record)">抽取密码</a> -->
                  <!-- <a-divider type="vertical"></a-divider> -->
                  <!-- <a @click="handleEvaluate(record)">专家抽取</a> -->
                  <a-divider type="vertical" />
                  <a @click="handleDetect(record)">检查清单</a>
                </span>
                <span v-else>
                  <a-popconfirm
                    title="确定操作?"
                    okText="确定"
                    cancelText="取消"
                    @confirm="() => handleSuspend(record)"
                  >
                    <a>中止</a>
                  </a-popconfirm>
                  <!-- <a-divider type="vertical" /> -->
                  <!-- <a @click="createPass(record)">抽取密码</a> -->
                  <!-- <a-divider type="vertical"></a-divider> -->
                  <!-- <a @click="handleEvaluate(record)">专家抽取</a> -->
                  <a-divider type="vertical" />
                  <a @click="handleDetect(record)">检查清单</a>
                </span>
              </span>
            </a-table>
          </a-col>
        </a-row>
        <a-modal
          title="生成密码"
          :visible="createVisible"
          okText="确定"
          @cancel="createCancel"
          @ok="createOk"
          v-if="createVisible"
          width="45%"
          :maskClosable="false"
        >
          <h3 style="text-align: center">{{ code }}</h3>
        </a-modal>
      </a-card>
      <!-- 专辑抽取 -->
      <a-card v-show="disvisible===1">
        <a-modal
          :visible="extractvisible"
          v-if="extractvisible"
          @cancel="handleExtractClose()"
          @ok="handleExtractOk()"
          title="专家抽取"
          :confirm-loading="extractLoading"
          okText="抽取"
          cancelText="取消"
          width="55%"
          :maskClosable="false"
        >
          <a-form-model
            ref="extractionrules"
            :label-col="{span: 6}"
            :wrapper-col="{span: 16}"
            :model="extractionrules"
          >
            <a-divider>抽取条件</a-divider>
            <a-form-model-item
              v-for="(item, index) in extractionrules.extract_rules"
              :key="index"
              :label="item.rule_name"
              :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }"
              :rules="{ required: true, message: '内容不可为空', trigger: 'blur' }"
              :prop="'extract_rules.' + index + '.rule_value'"
            >
              <!-- <a-input
                v-if="item.rule_type==1"
                v-model="item.rule_value"
              /> -->
              <a-input-number v-if="item.rule_type==1" id="inputNumber" v-model="item.rule_value" :min="0" :precision="0"/>
              <a-select v-if="item.rule_type==2" v-model="item.rule_value">
                <a-select-option v-for="itemtype in experttype" :key="itemtype.type_id" :value="itemtype.type_name">
                  {{ itemtype.type_name }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
            <br/>
            <a-divider>回避条件</a-divider>
            <a-form-model-item
              v-for="item in extractionrules.avoid_rules"
              :key="item.rule_id"
              :label="item.rule_name"
              :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }"
            >
              <a-input
                v-if="item.rule_type==1"
                v-model="item.rule_value"
                style="width:calc(80%);float: left"
              />
              <a-checkbox style="margin-left: 2%" @change="onChangeBox" v-if="item.rule_type==1" :value="item.rule_id" :checked="item.checked"> 选择</a-checkbox>
              <a-checkbox @change="onChangeBoxOne" v-if="item.rule_type==2" :value="item.rule_id" :checked="item.rule_value"> 选择 </a-checkbox>
            </a-form-model-item>
          </a-form-model>
        </a-modal>
        <h1 class="title_h">{{ projectname }}</h1>
        <a-button style="margin:5px" @click="backExtract">
          <a-icon type="rollback" />返回
        </a-button>
        <br/>
        <a-button style="margin:5px" @click="randomextract">专家抽取</a-button>
        <a-button style="margin:5px" @click="manualextract">手工抽取</a-button>
        <a-button style="margin:5px" :disabled="!posthasSelected&&!alterhasSelected" @click="audit(1)">审核</a-button>
        <a-button style="margin:5px" :disabled="!posthasSelected&&!alterhasSelected" @click="audit(2)">流号</a-button>
        <a-button style="margin:5px" :disabled="!posthasSelected&&!alterhasSelected" @click="audit(3)">删除</a-button>
        <p class="size_p">正选列表</p>
        <a-table
          :loading="positiveloading"
          :columns="positivecolumns"
          :row-selection="{ selectedRowKeys: selectedpositiveKeys, onChange: onpositiveChange, rowSelection: positiveSelection }"
          :pagination="positivepagination"
          :data-source="positivedataSource"
          :row-key="record => record.review_experts_id"
          bordered
        >
          <template slot="positiveaction" slot-scope="text, record">
            <a @click="handlepositive(record)">详情</a>
          </template>
        </a-table>
        <p class="size_h">备选列表</p>
        <a-table
          :loading="alternativeloading"
          :columns="alternativecolumns"
          :row-selection="{ selectedRowKeys: selectedalternativeKeys, onChange: onalternativeChange, rowSelection: alternativeSelection }"
          :pagination="alternativepagination"
          :data-source="alternativedataSource"
          :row-key="record => record.review_experts_id"
          bordered
        >
          <template slot="alternativeaction" slot-scope="text, record">
            <a @click="handlealternative(record)">详情</a>
          </template>
        </a-table>
        <a-modal
          title="输入抽取密码"
          :visible="passwordVisible"
          okText="确定"
          @cancel="passwordCancel"
          @ok="passwordOk"
          v-if="passwordVisible"
          width="45%"
          :maskClosable="false"
        >
          <a-form-model ref="pass" :model="pass" :label-col="{span: 7}" :wrapper-col="{span: 10}" :rules="{inputPassword: [{ required: true, message: '内容不可为空' }]}">
            <a-form-model-item label="抽取密码" prop="inputPassword">
              <a-input v-model="pass.inputPassword"></a-input>
            </a-form-model-item>
          </a-form-model>
        </a-modal>
        <a-modal
          title="专家详情"
          :visible="expertvisible"
          @cancel="detailsCancel"
          v-if="expertvisible"
          width="45%"
          :maskClosable="false"
        >
          <a-form-model :model="expertmessage" :label-col="{span: 7}" :wrapper-col="{span: 16} ">
            <a-form-model-item label="专家姓名" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.username" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家身份证号码" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.card_num" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家性别" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.sex" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家所属单位" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.company_name" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家手机号码" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.phone" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家职称" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.experts_title" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="职称专业" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.title_major" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专业资格" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.major_status" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="专家论证类别" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-select mode="multiple" style="width: 100%" v-model="expertmessage.experts_types" :disabled="true"></a-select>
            </a-form-model-item>
            <a-form-model-item label="专家级别" prop="experts_level" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.experts_level" :disabled="true"></a-input>
            </a-form-model-item>
            <a-form-model-item label="本人证件照" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-upload
                :file-list="expertmessage.my_photo"
                @preview="handlePreview"
                list-type="picture-card"
              ></a-upload>
            </a-form-model-item>
            <a-form-model-item label="身份证文件" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-upload
                :file-list="expertmessage.my_card_photo"
                @preview="handlePreview"
                list-type="picture-card"
              ></a-upload>
            </a-form-model-item>
            <a-form-model-item label="学历证明文件" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-upload
                :file-list="expertmessage.academic_credentials"
                @preview="handlePreview"
                list-type="picture-card"
              ></a-upload>
            </a-form-model-item>
            <a-form-model-item label="职称文件" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-upload
                :file-list="expertmessage.title_document"
                @preview="handlePreview"
                list-type="picture-card"
              ></a-upload>
            </a-form-model-item>
            <a-form-model-item label="执业资格文件" prop="" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-upload
                :file-list="expertmessage.practice_qualification_certificate"
                @preview="handlePreview"
                list-type="picture-card"
              ></a-upload>
            </a-form-model-item>
            <a-form-model-item label="备注" prop="remarks" :style="{ display: 'inline-block', width: 'calc(50% - 12px)' }">
              <a-input v-model="expertmessage.remarks" :disabled="true"></a-input>
            </a-form-model-item>
          </a-form-model>
          <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancelimg">
            <img alt="example" style="width: 100%" :src="previewImage" />
          </a-modal>
          <template slot="footer">
            <Button type="button" class="ant-btn" @click="detailsCancel">取消</Button>
          </template>
          <a-table :columns="expertcolumns" :data-source="expertdataSource" :pagination="false" bordered></a-table>
        </a-modal>
        <a-modal :visible="manualvisible" @cancel="manualCancel" width="55%" :maskClosable="false">
          <a-button type="primary" :disabled="!manualSelected" :loading="manualloading" style="margin-top:30px" @click="manualadd">
            添加
          </a-button>
          <a-input-search
            placeholder="输入您要搜索的内容"
            @search="onSearchmanual"
            style="width:25%;float:right;margin-top:30px"
            v-model="searchmanual"
            enter-button
          />
          <a-table
            :loading="manualloading"
            :columns="manualcolumns"
            :row-selection="{ selectedRowKeys: selectedmanualKeys, onChange: onmanualChange, rowSelection: manualSelection }"
            :pagination="manualpagination"
            :data-source="manualdataSource"
            :row-key="record => record.experts_id"
            bordered
            @change="handleTableChangemanual"
          >
            <template slot="manualaction" slot-scope="text, record">
              <a @click="handlemanual(record)">详情</a>
            </template>
          </a-table>
          <template slot="footer">
            <a-button @click="manualCancel">关闭</a-button>
          </template>
        </a-modal>
      </a-card>
      <!-- 检查清单 -->
      <a-card v-show="disvisible===2">
        <h1 class="title_h">{{ projectname }}</h1>
        <a-button style="margin-bottom:5px" @click="backDetect">
          <a-icon type="rollback" />返回
        </a-button>
        <a-collapse v-model="activeKey" expand-icon-position="right">
          <a-collapse-panel v-for="(item, i) in Checklist" :key="`${i}`" :header="item.list_name">
            <h3>核选项</h3>
            <a-table
              :columns="nuclearOptioncolumns"
              :pagination="false"
              :data-source="item.check_list"
            >
              <template slot="nuclearDistribute" slot-scope="text, record">
                <span v-if="record.review_experts_id">
                  <a @click="handleNuclearDelete(record)">删除</a>
                </span>
                <span v-else>
                  <a @click="handleNuclearAdd(record)">添加</a>
                </span>
              </template>
            </a-table>
            <h3 style="margin-top:14px">评分项</h3>
            <a-table
              :columns="scoringItemcolumns"
              :pagination="false"
              :data-source="item.score_list"
            >
              <template slot="scoringDistribute" slot-scope="text, record">
                <span v-if="record.review_experts_id">
                  <a @click="handleScoringDelete(record)">删除</a>
                </span>
                <span v-else>
                  <a @click="handleScoringAdd(record)">添加</a>
                </span>
              </template>
            </a-table>
          </a-collapse-panel>
        </a-collapse>
        <a-modal :visible="allocationVisible" @cancel="allocationCancel" width="45%" :maskClosable="false">
          <a-table
            :columns="allocationcolumns"
            :pagination="false"
            :data-source="allocationDataSource"
            style="margin: 20px"
          >
            <template slot="choose" slot-scope="text, record">
              <a @click="addChecklist(record)">添加</a>
            </template>
          </a-table>
          <template slot="footer">
            <a-button @click="allocationCancel">关闭</a-button>
          </template>
        </a-modal>
        <a-button type="primary" style="float: right; margin-top: 5px" @click="saveChecklist">保存</a-button>
      </a-card>
    </div>
  </page-header-wrapper>
</template>

<script>
import moment from 'moment'
import STree from '@/components/Tree/Tree'
import { STable } from '@/components'
import OrgModal from '../other/modules/OrgModal'
// import { getServiceList } from '@/api/manage'
// eslint-disable-next-line no-unused-vars
import { menuFinds, askTable, mobilemod, extract, getxtractionrules, getexperttype, gethandmess, getauditmess, reviewsearch, operateextract, createCode, usePassword } from '@/api/mobileReviewExtract'
import { getlist, getTable, sendList } from '@/api/mobileReviewDetect'

const delay = (function () {
 let timer = 0
 return function (callback, ms) {
  clearTimeout(timer)
  timer = setTimeout(callback, ms)
 }
})()
export default {
  name: 'TreeList',
  components: {
    STable,
    STree,
    OrgModal
  },
  data () {
    return {
      visibleLook: false,
      menuLoading: true,
      searchText: '',
      disvisible: 0,
      expertvisible: false,
      projectname: '',
      extractvisible: false, // 专家抽取
      fileList: [],
      filepdf: true,
      searchmanual: '',
      expertmessage: {
        my_photo: [],
        my_card_photo: [],
        academic_credentials: [],
        title_document: [],
        practice_qualification_certificate: []
      }, // 列表专家信息
      avoidancevalue: {}, // 回避条件
      confirmLoading: false,
      experttype: '',
      confirmLoadingreport: false,
      extractLoading: false,
      projectTypeId: 1,
      loading: true,
      openKeys: ['1'],
      treespan: 4,
      tablespan: 20,
      dataSource: [],
      originalData: [],
      pagination: {
        pageSize: 10,
        current: 1,
        total: 0,
        showSizeChanger: true,
        pageSizeOptions: ['10', '20', '30', '50']
      },
      extractionrules: {},
      // 查询参数
      queryParam: new FormData(),
      // 表头
      columns: [],
      orgTree: [],
      selectedRowKeys: [],
      selectedRows: [],
      passwordVisible: false,
      createVisible: false,
      code: '',
      pass: {},
      // 正选列表
      positiveloading: false,
      positivecolumns: [
        {
          title: '序号',
          dataIndex: 'index',
          key: 'index',
          align: 'center',
          width: 70,
          customRender: (text, record, index) => `${index + 1}`
        },
        {
          title: '姓名',
          dataIndex: 'username'
        },
        {
          title: '小组职务',
          dataIndex: 'job'
        },
        {
          title: '专家级别',
          dataIndex: 'experts_level'
        },
        {
          title: '专家职称',
          dataIndex: 'experts_title'
        },
        {
          title: '单位名称',
          dataIndex: 'company_name'
        },
        {
          title: '审核情况',
          dataIndex: 'audit_status'
        },
        {
          title: '操作',
          dataIndex: 'positiveaction',
          align: 'center',
          // width: 209,
          // fixed: 'right',
          scopedSlots: { customRender: 'positiveaction' }
        }
      ],
      selectedpositiveKeys: [],
      positiveSelection: [],
      positivedataSource: [],
      positivepagination: false,
      // 备选列表
      alternativeloading: false,
      alternativecolumns: [
        {
          title: '序号',
          dataIndex: 'index',
          key: 'index',
          align: 'center',
          width: 70,
          customRender: (text, record, index) => `${index + 1}`
        },
        {
          title: '姓名',
          dataIndex: 'username'
        },
        {
          title: '小组职务',
          dataIndex: 'job'
        },
        {
          title: '专家级别',
          dataIndex: 'experts_level'
        },
        {
          title: '专家职称',
          dataIndex: 'experts_title'
        },
        {
          title: '单位名称',
          dataIndex: 'company_name'
        },
        {
          title: '审核情况',
          dataIndex: 'audit_status'
        },
        {
          title: '操作',
          dataIndex: 'alternativeaction',
          align: 'center',
          // width: 209,
          // fixed: 'right',
          scopedSlots: { customRender: 'alternativeaction' }
        }
      ],
      selectedalternativeKeys: [],
      alternativeSelection: [],
      alternativedataSource: [],
      alternativepagination: false,
      // 手工抽取列表
      manualvisible: false,
      manualloading: false,
      manualcolumns: [
        {
          title: '序号',
          dataIndex: 'index',
          key: 'index',
          align: 'center',
          width: 70,
          customRender: (text, record, index) => `${index + 1}`
        },
        {
          title: '姓名',
          dataIndex: 'username'
        },
        {
          title: '手机',
          dataIndex: 'phone'
        },
        {
          title: '专家级别',
          dataIndex: 'experts_level'
        },
        {
          title: '专家职称',
          dataIndex: 'experts_title'
        },
        {
          title: '单位名称',
          dataIndex: 'company_name'
        },
        {
          title: '轮空值',
          dataIndex: 'skip_num'
        },
        {
          title: '操作',
          dataIndex: 'manualaction',
          align: 'center',
          // width: 209,
          // fixed: 'right',
          scopedSlots: { customRender: 'manualaction' }
        }
      ],
      selectedmanualKeys: [],
      manualSelection: [],
      manualdataSource: [],
      manualpagination: {
        current: 1,
        pageSize: 10,
        total: 0,
        showSizeChanger: true,
        pageSizeOptions: ['10', '20', '30', '50']
      },
      // 专家详情table
      expertdataSource: [],
      expertcolumns: [
        {
          title: '工程名称',
          dataIndex: '工程名称'
        },
        {
          title: '职务',
          dataIndex: 'job'
        },
        {
          title: '审核情况',
          dataIndex: 'audit_status'
        },
        {
          title: '抽取类型',
          dataIndex: 'extract_type'
        }
      ],
      previewVisible: false,
      previewImage: '',
      // 检查清单页面
      activeKey: [0],
      nuclearOptioncolumns: [
        {
          title: '文件名称',
          dataIndex: 'list_child_name'
        },
        {
          title: '主要检查内容与方法',
          dataIndex: 'list_child_desc'
        },
        {
          title: '类别',
          dataIndex: 'list_child_type'
        },
        {
          title: '专家姓名',
          dataIndex: 'review_experts_name'
        },
        {
          title: '分配专家',
          dataIndex: 'nuclearDistribute',
          scopedSlots: { customRender: 'nuclearDistribute' },
          align: 'center',
          width: 120
        }
      ],
      scoringItemcolumns: [
        {
          title: '文件名称',
          dataIndex: 'list_child_name'
        },
        {
          title: '满分值',
          dataIndex: 'list_child_score'
        },
        {
          title: '类别',
          dataIndex: 'list_child_type'
        },
        {
          title: '专家姓名',
          dataIndex: 'review_experts_name'
        },
        {
          title: '分配专家',
          dataIndex: 'scoringDistribute',
          scopedSlots: { customRender: 'scoringDistribute' },
          align: 'center',
          width: 120
        }
      ],
      Checklist: [],
      allocationVisible: false,
      review_definition_id: '',
      allocationcolumns: [
        {
          title: '专家名称',
          dataIndex: 'review_experts_name'
        },
        {
          title: '类别',
          dataIndex: 'title'
        },
        {
          title: '分配专家',
          dataIndex: 'choose',
          scopedSlots: { customRender: 'choose' },
          align: 'center',
          width: 120
        }
      ],
      allocationDataSource: []
    }
  },
  watch: {
    searchmanual: function (newVal, oldVal) {
      delay(() => {
        this.onSearchmanual(newVal)
      }, 1000)
    },
    activeKey (key) {
      console.log(key)
    }
  },
  computed: {
    posthasSelected () {
      return this.selectedpositiveKeys.length > 0
    },
    alterhasSelected () {
      return this.selectedalternativeKeys.length > 0
    },
    manualSelected () {
      return this.selectedmanualKeys.length > 0
    }
  },
  created () {
    this.getMenuInfo()
  },
  methods: {
    moment,
    // 图片预览模态框
    handlePreview (file) {
      this.previewImage = file.url
      this.previewVisible = true
    },
    handleCancelimg () {
      this.previewVisible = false
      this.previewImage = ''
    },
    onSearchmanual () {
      var searchmanualmess = new FormData()
      searchmanualmess.append('query', this.searchmanual)
      searchmanualmess.append('per_page', this.manualpagination.pageSize)
      searchmanualmess.append('current_page', this.manualpagination.current)
      reviewsearch(searchmanualmess).then(res => {
        this.manualdataSource = res.result.data
        console.log(this.manualdataSource)
        Object.assign(this.manualpagination, { 'pageSize': Number(res.result.per_page), 'total': res.result.total, 'current': res.result.current_page })
      })
    },
    // handleEvaluate (record) { 专家抽取事件
    //   this.projectname = record.工程名称
    //   this.disvisible = 1
    //   getxtractionrules().then(res => {
    //     Object.assign(res.result, { 'review_definition_id': Number(record.review_definition_id) })
    //     this.extractionrules = res.result
    //     console.log(this.extractionrules)
    //   })
    //   var reviewmessid = new FormData()
    //   reviewmessid.append('review_definition_id', record.review_definition_id)
    //   getauditmess(reviewmessid).then(res => {
    //     if (res.code === 200) {
    //       this.positivedataSource = res.result.real
    //       this.alternativedataSource = res.result.optional
    //       this.positiveloading = true
    //       this.alternativeloading = true
    //     }
    //     setTimeout(() => {
    //       this.positiveloading = false
    //       this.alternativeloading = false
    //     }, 500)
    //   })
    // },
    onChangeBox (e) {
      console.log(e.target.value)
      this.extractionrules.avoid_rules.some((item) => {
        if (item.rule_id === e.target.value) {
          item.checked = e.target.checked
          return true
        }
      })
    },
    onChangeBoxOne (e) {
      console.log(e)
      console.log(e.target.value)
      this.extractionrules.avoid_rules.some((item) => {
        if (item.rule_id === e.target.value) {
          item.rule_value = e.target.checked
          item.checked = e.target.checked
          return true
        }
      })
      console.log(this.extractionrules)
    },
    onpositiveChange (selectedRowKeys, rowSelection) {
      this.selectedpositiveKeys = selectedRowKeys
      this.positiveSelection = rowSelection
    },
    onalternativeChange (selectedRowKeys, rowSelection) {
      this.selectedalternativeKeys = selectedRowKeys
      this.alternativeSelection = rowSelection
    },
    onmanualChange (selectedRowKeys, rowSelection) {
      this.selectedmanualKeys = selectedRowKeys
      this.manualSelection = rowSelection
      // console.log(selectedRowKeys)
    },
    handleTableChangemanual (pagination) {
      this.manualpagination.current = pagination.current
      this.manualpagination.pageSize = pagination.pageSize
      if (this.searchmanual) {
        this.onSearchmanual()
      } else {
        this.manualextract()
      }
    },
    // 撤销
    handleRevoke (record) {
      var revokeoperation = new FormData()
      revokeoperation.append('review_definition_id', record.review_definition_id)
      revokeoperation.append('operate', 'draw_back')
      mobilemod(revokeoperation).then(res => {
        if (res.code === 200) {
          this.$message.success(res.result)
          this.getTableData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // 中止
    handleSuspend (record) {
      var suspendperation = new FormData()
      suspendperation.append('review_definition_id', record.review_definition_id)
      suspendperation.append('operate', 'stop_review')
      mobilemod(suspendperation).then(res => {
        if (res.code === 200) {
          this.$message.success(res.result)
          this.getTableData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // 移动端启动
    onChangeMobile (record) {
      var mobileoperation = new FormData()
      mobileoperation.append('review_definition_id', record.review_definition_id)
      mobileoperation.append('operate', 'switch_mobile')
      mobileoperation.append('switch_status', !record.is_mobile)
      mobilemod(mobileoperation).then(res => {
        if (res.code === 200) {
          this.$message.success(res.result)
          this.getTableData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    // 左侧树点击
    handleClick (e) {
      console.log('handleClick', e)
      this.projectTypeId = e.key
      // this.$refs.table.refresh(true)
      this.getTableData()
    },
    handleTitleClick (item) {
      console.log('handleTitleClick', item)
    },
    titleClick (e) {
      console.log('titleClick', e)
    },
    handlepositive (record) {
      console.log(record)
      this.expertvisible = true
      this.expertmessage = JSON.parse(JSON.stringify(record))
      this.expertdataSource = JSON.parse(JSON.stringify(record.past_project))
    },
    handlealternative (record) {
      console.log(record)
      this.expertvisible = true
      this.expertmessage = JSON.parse(JSON.stringify(record))
      this.expertdataSource = JSON.parse(JSON.stringify(record.past_project))
    },
    handlemanual (record) {
      this.expertvisible = true
      this.expertmessage = JSON.parse(JSON.stringify(record))
      this.expertdataSource = JSON.parse(JSON.stringify(record.past_project))
    },
    detailsCancel () {
      this.expertvisible = false
      this.expertmessage = {
        my_photo: [],
        my_card_photo: [],
        academic_credentials: [],
        title_document: [],
        practice_qualification_certificate: []
      }
    },
    handleExtractOk () {
      this.$refs['extractionrules'].validate(valid => {
        console.log(valid)
        if (!valid) {
          return false
        } else {
          this.extractLoading = true
          this.passwordVisible = true
          setTimeout(() => {
            this.extractLoading = false
          }, 1000)
        }
      })
    },
    handleExtractClose () {
      this.extractvisible = false
    },
    passwordOk () {
      this.$refs.pass.validate(valid => {
        console.log(valid)
        if (!valid) {
          return false
        } else {
          var verify = new FormData()
          verify.append('item_type', 'review')
          verify.append('item_id', this.extractionrules.review_definition_id)
          verify.append('extract_password', this.pass.inputPassword)
          usePassword(verify).then(res => {
            if (res.code === 200) {
              extract(this.extractionrules).then(res => {
                if (res.code === 200) {
                  this.$message.success('抽取成功')
                  console.log(typeof (res.result))
                  this.positivedataSource = res.result.real
                  this.alternativedataSource = res.result.optional
                  this.positiveloading = true
                  this.alternativeloading = true
                } else {
                  this.$message.error(res.message)
                }
                setTimeout(() => {
                  this.positiveloading = false
                  this.alternativeloading = false
                  this.extractLoading = false
                  this.handleExtractClose()
                  this.passwordCancel()
                }, 500)
              })
              this.passwordVisible = false
            } else {
              this.$message.error('密码错误')
            }
          })
        }
      })
    },
    passwordCancel () {
      this.passwordVisible = false
      this.pass = {}
    },
    // createPass (record) { //抽取密码事件
    //   var create = new FormData()
    //   create.append('item_type', 'review')
    //   create.append('item_id', record.review_definition_id)
    //   createCode(create).then(res => {
    //     if (res.code === 200) {
    //       console.log(res.result)
    //       this.code = res.result[0]
    //       console.log(this.code)
    //     } else {
    //       this.code = res.message
    //     }
    //   })
    //   this.createVisible = true
    // },
    createOk () {
      this.createVisible = false
    },
    createCancel () {
      this.createVisible = false
    },
    // 获取左侧树状信息
    getMenuInfo () {
      // this.loading = true
      this.menuLoading = true
      menuFinds().then(res => {
        this.orgTree = res.result
        // 获取menu后表格默认显示第一个menu的数据
        this.projectTypeId = this.orgTree[0].key
        this.getTableData()
        this.menuLoading = false
        // this.loading = false
      })
    },
    // 列搜索
    handleSearch (selectedKeys, confirm, dataIndex) {
      confirm()
      this.searchText = selectedKeys[0]
      this.searchedColumn = dataIndex
    },
    // 列搜索重置
    handleReset (clearFilters) {
      clearFilters()
      this.searchText = ''
    },
    // 对动态请求到的表头数组遍历插入列搜索相关slot及函数 详见ant design vue文档
    headerPush (data) {
      data.forEach(item => {
        item['scopedSlots'] = { filterDropdown: 'filterDropdown', filterIcon: 'filterIcon', customRender: 'customRender' }
        item['onFilter'] = (value, record) =>
            record[item.dataIndex]
              .toString()
              .toLowerCase()
              .includes(value.toLowerCase())
        item['onFilterDropdownVisibleChange'] = visible => {
          if (visible) {
            setTimeout(() => {
              this.searchInput.focus()
            }, 0)
          }
        }
      })
    },
    // 获取表头及数据
    getTableData () {
      this.loading = true
      var formdata = new FormData()
      formdata.append('project_type_id', this.projectTypeId)
      askTable(formdata).then(res => {
        this.columns = res.result.headList
        this.headerPush(this.columns)
        this.columns.push({ title: '评审状态', dataIndex: 'review_status' })
        this.columns.push({ title: '专业', dataIndex: 'review_major' })
        this.columns.push({ title: '移动端启用', dataIndex: 'mobile', scopedSlots: { customRender: 'mobile' }, key: 'mobile' })
        this.columns.push({ title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, key: 'action', align: 'center', fixed: 'right', width: 210 })
        console.log(this.columns)
        this.dataSource = res.result.data.data
        this.originalData = res.result.data.data
        this.pagination.total = res.result.data.total
        this.loading = false
      })
    },
    // 左侧树状菜单收缩
    turnSmall () {
      this.tablespan === 20 ? this.tablespan = 24 : this.tablespan = 20
      this.treespan === 0 ? this.treespan = 4 : this.treespan = 0
    },
    randomextract () {
      this.extractvisible = true
      var type = new FormData()
      type.append('type_kinds', '0')
      getexperttype(type).then(res => {
        this.experttype = res.result.data
      })
    },
    audit (value) {
      var auditnums = []
      auditnums = this.selectedpositiveKeys.concat(this.selectedalternativeKeys)
      // console.log(auditnums)
      // console.log(this.extractionrules.argument_id)
      var auditmess = {}
      if (value === 1) {
        auditmess = {
          'review_definition_id': this.extractionrules.review_definition_id,
          'review_experts_id': auditnums,
          'operation': 'audit'
        }
      } else if (value === 2) {
        auditmess = {
          'review_definition_id': this.extractionrules.review_definition_id,
          'review_experts_id': auditnums,
          'operation': 'flow'
        }
      } else {
        auditmess = {
          'review_definition_id': this.extractionrules.review_definition_id,
          'review_experts_id': auditnums,
          'operation': 'delete'
        }
      }
      operateextract(auditmess).then(res => {
        if (res.code === 200) {
          this.$message.success(res.result)
          var id = new FormData()
          id.append('review_definition_id', this.extractionrules.review_definition_id)
          getauditmess(id).then(resu => {
            if (resu.code === 200) {
              this.positivedataSource = resu.result.real
              this.alternativedataSource = resu.result.optional
              this.positiveloading = true
              this.alternativeloading = true
            }
            setTimeout(() => {
              this.positiveloading = false
              this.alternativeloading = false
              this.selectedpositiveKeys = []
              this.positiveSelection = []
              this.selectedalternativeKeys = []
              this.alternativeSelection = []
            }, 900)
          })
        } else {
          this.$message.error(res.message)
        }
      })
    },
    manualextract () {
      this.manualvisible = true
      var handmess = new FormData()
      console.log(this.extractionrules.review_definition_id)
      handmess.append('per_page', this.manualpagination.pageSize)
      handmess.append('current_page', this.manualpagination.current)
      handmess.append('review_definition_id', this.extractionrules.review_definition_id)
      gethandmess(handmess).then(res => {
        this.manualdataSource = res.result?.data
        // console.log(this.manualdataSource)
        if (this.manualdataSource) {
        // eslint-disable-next-line
        Object.assign(this.manualpagination, { 'pageSize': Number(res.result?.per_page), 'total': res.result?.total, 'current': res.result?.current_page })
        }
        this.$options.methods.onSearchmanual.bind(this)()
      })
    },
    manualadd () {
      var addmess = {
        'review_definition_id': this.extractionrules.review_definition_id,
        'review_experts_id': this.selectedmanualKeys,
        'operation': 'add_hand'
      }
      this.positiveloading = true
      this.alternativeloading = true
      operateextract(addmess).then(res => {
        if (res.code === 200) {
          this.$message.success('手动抽取成功')
          var manualid = new FormData()
          manualid.append('review_definition_id', this.extractionrules.review_definition_id)
          getauditmess(manualid).then(res => {
            if (res.code === 200) {
              this.positivedataSource = res.result.real
              this.alternativedataSource = res.result.optional
              this.positiveloading = false
              this.alternativeloading = false
            }
            setTimeout(() => {
              this.positiveloading = false
              this.alternativeloading = false
              this.selectedmanualKeys = []
              this.manualSelection = []
            }, 500)
          })
        }
      })
      this.manualCancel()
    },
    manualCancel () {
      this.manualvisible = false
      this.selectedmanualKeys = []
      this.manualSelection = []
    },
    handleModalClose () {
      this.visible = false
      this.visibleLook = false
      this.showData.domains = []
      this.fileList = []
    },
    // 前端分页
    handlePageChange (pagination) {
      this.pagination.current = pagination.current
      this.pagination.pageSize = pagination.pageSize
      this.dataSource = JSON.parse(JSON.stringify(this.originalData))
      this.dataSource = this.dataSource.slice((this.pagination.current - 1) * this.pagination.pageSize, this.pagination.current * this.pagination.pageSize)
      // console.log(this.dataSource)
    },
    backExtract () {
      this.disvisible = 0
      this.positivedataSource = []
      this.alternativedataSource = []
    },
    // 检查清单页面
    handleDetect (record) {
      console.log(record)
      this.review_definition_id = record.review_definition_id
      this.projectname = record.工程名称
      this.disvisible = 2
      var list = {
        list_major: record.review_major,
        review_definition_id: record.review_definition_id
      }
      getlist(list).then(res => {
        if (res.code === 200) {
          this.Checklist = res.result
        }
      })
      var nuclearmess = {
        review_definition_id: record.review_definition_id
      }
      getTable(nuclearmess).then(res => {
        if (JSON.stringify(res.result) === '{}') {
          this.$message.error('获取分配专家列表失败')
        } else {
          this.allocationDataSource = res.result
        }
      })
    },
    backDetect () {
      this.disvisible = 0
      this.allocationDataSource = []
    },
    handleNuclearAdd (record) {
      console.log(record)
      this.allocationDataSource.forEach(item => {
        Object.assign(item, { 'list_child_id': record.list_child_id, 'type': 'Nuclear' })
      })
      this.allocationVisible = true
    },
    handleScoringAdd (record) {
      console.log(record)
      this.allocationDataSource.forEach(item => {
        Object.assign(item, { 'list_child_id': record.list_child_id, 'type': 'Scoring' })
      })
      this.allocationVisible = true
    },
    handleNuclearDelete (record) {
      console.log(record)
      Object.assign(record, { 'review_experts_id': '', 'review_experts_name': '' })
      this.$message.success('删除成功')
    },
    handleScoringDelete (record) {
      console.log(record)
      Object.assign(record, { 'review_experts_id': '', 'review_experts_name': '' })
      this.$message.success('删除成功')
    },
    allocationCancel () {
      this.allocationVisible = false
    },
    saveChecklist () {
      var CheckListmess = {
        review_definition_id: this.review_definition_id,
        list: this.Checklist
      }
      sendList(CheckListmess).then(res => {
        if (res.code === 200) {
          this.$message.success('保存成功')
        }
      })
    },
    addChecklist (record) {
      console.log(record)
      if (record.type === 'Nuclear') {
        this.Checklist.forEach(item => {
          item.check_list.some((item) => {
            if (item.list_child_id === record.list_child_id) {
              Object.assign(item, { 'review_experts_id': record.review_experts_id, 'review_experts_name': record.review_experts_name })
              this.$message.success('添加成功')
              this.allocationVisible = false
            }
          })
        })
      } else {
        this.Checklist.forEach(item => {
          item.score_list.some((item) => {
            if (item.list_child_id === record.list_child_id) {
              Object.assign(item, { 'review_experts_id': record.review_experts_id, 'review_experts_name': record.review_experts_name })
              this.$message.success('添加成功')
              this.allocationVisible = false
            }
          })
        })
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .size_p{
    font-size: 20px;
    margin: 5px;
  }
  .title_h{
    font-size: 30px;
  }
  .size_h{
    font-size: 20px;
    margin: 5px;
  }
  .custom-tree {

    /deep/ .ant-menu-item-group-title {
      position: relative;
      &:hover {
        .btn {
          display: block;
        }
      }
    }

    /deep/ .ant-menu-item {
      &:hover {
        .btn {
          display: block;
        }
      }
    }

    /deep/ .btn {
      display: none;
      position: absolute;
      top: 0;
      right: 10px;
      width: 20px;
      height: 40px;
      line-height: 40px;
      z-index: 1050;

      &:hover {
        transform: scale(1.2);
        transition: 0.5s all;
      }
    }
  }
  .turnSmall{
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s;
    position: relative;
    top: -10px;
  }
  .turnSmall:hover {
    color: #33AAFF;
    background-color: #F0F2F5;
  }
  /deep/ .ant-modal-content{
    width: 150%;
    left: -24%;
  }
.highlight {
  background-color: rgb(255, 192, 105);
  padding: 0px;
}
</style>
